package com.etc.service.impl;

import com.etc.dao.VideoPersonageDao;
import com.etc.pojo.Video;
import com.etc.service.VideoPersonageService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VideoPersonageServiceImpl implements VideoPersonageService {

    @Autowired
    VideoPersonageDao videoDao;

    @Override
    public PageInfo<Video> queryAllVideoByUserId(String userId, Integer pageNum) {
        PageHelper.startPage(pageNum,6);
        List<Video> videos = videoDao.queryAllVideoByUserId(userId);
        PageInfo<Video> pageInfo = new PageInfo<>(videos);
        return pageInfo;
    }

    @Override
    public boolean deleteVideoByVideoId(String videoId,int videoState) {
        int leep = videoDao.deleteVideoByVideoId(videoId,videoState);
        return leep>0;
    }

    @Override
    public boolean addVideo(Video video) {
        int leep = videoDao.addVideo(video);
        return leep>0;
    }

    @Override
    public boolean addVipVideo(Video video) {
        int leep = videoDao.addVipVideo(video);
        return leep>0;
    }
}
